<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base href="#(basePath)"/>
  <title>清算管理 - 收入列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="static/admin.css" media="all">
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-card">
      <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">起始日期</label>
            <div class="layui-input-inline">
              <input type="text" name="settleDateStart" id="settleDateStart" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">结束日期</label>
            <div class="layui-input-inline">
              <input type="text" name="settleDateEnd" id="settleDateEnd" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
          </div>
          <div class="layui-inline">
            <label class="layui-form-label">渠道</label>
            <div class="layui-input-inline">
	            <select name="channelCode" lay-filter="channelCode">
	       			<option value="">请选择</option>
	       			#for(item : channelList)
	      				<option value="#(item.code)">#(item.name)</option>
	      			#end
	      		</select>
            </div>
          </div>
          <div class="layui-inline">
            <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-web-list-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
            #auth()
            <button link="admin/clearing/income/getChannelIncome" class="layui-btn layuiadmin-btn-list" data-type="add">提取</button>
            #end
          </div>
        </div>
      </div>

      <div class="layui-card-body">
        <table id="LAY-web-list" lay-filter="LAY-web-list"></table>
      </div>
    </div>
  </div>

  <script src="static/layui/layui.js"></script>
  <script>
  layui.config({
    base: '#(basePath)' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'table', 'laydate', 'income'], function(){
	 var laydate = layui.laydate;
	   //日期时间选择器
	   laydate.render({
	     elem: '#settleDateStart'
	     ,type: 'date'
	   });
	   //日期时间选择器
	   laydate.render({
	     elem: '#settleDateEnd'
	     ,type: 'date'
	   });
    // 表格
    var table = layui.table
    ,form = layui.form;
    
    //监听搜索
    form.on('submit(LAY-web-list-search)', function(data){
      var field = data.field;
      
      //执行重载
      table.reload('LAY-web-list', {
        where: field,
        page: {curr: 1}
      });
    });
    
    var $ = layui.$, 
    active = {
      add: function(){
    		// 请求提取渠道收入接口
		layui.admin.req({
			url : layui.setter.base
					+ "admin/clearing/income/getChannelIncome?settleDate=" + $("#settleDateStart").val()
					+ "&r=" + Math.random(),
			data : null,
			done : function(res) {
				layer.msg(res.msg, {
					offset : '15px',
					icon : 1,
					time : 1000
				}, function() {
					table.reload('LAY-web-list'); //重载表格
				});
			}
		});
		// 关闭
		layer.close(e);
      }
    }; 

    $('.layui-btn.layuiadmin-btn-list').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
    	    
  });
  </script>
</body>
</html>